﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using ComicIsland.Common.Entities.LocalJson;

/**
 * 创建时间：2015/1/17 16:36:43
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace ComicIsland.App.Views.DTSelector
{
    public class BookcaseAdTemplateSelector : DataTemplateSelector
    {
        /// <summary>
        /// 广告控件
        /// </summary>
        public DataTemplate AdArea { get; set; }

        /// <summary>
        /// 收藏的漫画数据
        /// </summary>
        public DataTemplate ComicArea { get; set; }

        /// <summary>
        /// 根据属性，返回对应的DataTemplate 
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="container"></param>
        /// <returns></returns>

        public override DataTemplate SelectTemplate(object obj, DependencyObject container)
        {
            LocalBookcaseInfo item = obj as LocalBookcaseInfo;
            if (item != null)
            {
                if (item.IsAd)
                {
                    return AdArea;
                }
                else
                {
                    return ComicArea;
                }
            }
            return base.SelectTemplate(item, container);
        }
    }
}
